package cn.blossoming.service.base;

import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

import java.io.Serializable;
import java.util.List;

public interface BaseService<T, ID extends Serializable> {

    List<T> findAll();


    List<T> findAll(Sort sort);


    List<T> findAll(Iterable<ID> iterable);


    <S extends T> List<S> save(Iterable<S> iterable);


    void flush();


    <S extends T> S saveAndFlush(S s);


    void deleteInBatch(Iterable<T> iterable);


    void deleteAllInBatch();


    T getOne(ID id);


    <S extends T> List<S> findAll(Example<S> example);


    <S extends T> List<S> findAll(Example<S> example, Sort sort);


    Page<T> findAll(Pageable pageable);


    <S extends T> S save(S s);


    T findOne(ID id);


    boolean exists(ID id);


    long count();


    void delete(ID id);


    void delete(T t);


    void delete(Iterable<? extends T> iterable);


    void deleteAll();


    <S extends T> S findOne(Example<S> example);


    <S extends T> Page<S> findAll(Example<S> example, Pageable pageable);


    <S extends T> long count(Example<S> example);


    <S extends T> boolean exists(Example<S> example);
}
